var t = getApp();

Page({
    data: {
        language: "",
        plugin_type: "",
        plugin_text: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        earningList: [],
        adv_thumb: "",
        adv_url: "",
        income: 0,
        reward_type: "",
        lat: "",
        lng: ""
    },
    onLoad: function(t) {
        t.plugin_type && this.setData({
            plugin_type: t.plugin_type,
            plugin_text: t.plugin_text
        }), this.loaction(), this._getData();
    },
    loaction: function() {
        var t = wx.getStorageSync("address-point");
        t && t.point ? this.setData({
            lat: t.point.lat,
            lng: t.point.lng
        }) : this.setData({
            lat: "",
            lng: ""
        });
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    _getData: function() {
        var a = this;
        a.setData({
            isLoadMore: !1,
            page: 1
        });
        var e = t.getNetAddresss("finance.plugin-settle.get-not-settle-list");
        e += "&plugin_type=" + a.data.plugin_type, t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.setData({
                    isLoadMore: !0,
                    total_page: e.data.last_page
                }), a.data.total_page || a.setData({
                    total_page: 0
                }), a.setData({
                    earningList: e.data.data
                })) : a.setData({
                    earningList: e.data
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    _getMoreData: function() {
        var a = this;
        if (a.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            a.setData({
                page: a.data.page + 1
            });
            var e = t.getNetAddresss("finance.plugin-settle.get-not-settle-list");
            e += "&plugin_type=" + a.data.plugin_type, e += "&page=" + a.data.page, t._getNetWork({
                url: e,
                success: function(t) {
                    var e = t.data;
                    if (a.setData({
                        isLoadMore: !0
                    }), 1 == e.result) {
                        var n = e.data.data;
                        a.setData({
                            earningList: a.data.earningList.concat(n)
                        });
                    } else a.setData({
                        page: a.data.page - 1,
                        isLoadMore: !1
                    });
                },
                fail: function(t) {
                    console.log(t.msg);
                }
            });
        }
    },
    getAdvertising: function(a) {
        var e = this, n = a.currentTarget.dataset.id;
        e.setData({
            adv_thumb: "",
            adv_url: "",
            income: 0
        });
        var i = t.getNetAddresss("finance.plugin-settle.income-receive");
        i += "&plugin_type=" + e.data.plugin_type, i += "&id=" + n, i += "&lng=" + this.data.lng, 
        i += "&lat=" + this.data.lat, t._getNetWork({
            url: i,
            success: function(t) {
                var a = t.data;
                1 == a.result ? (e.setData({
                    adv_thumb: a.data.adv_thumb,
                    adv_url: a.data.adv_url,
                    income: a.data.income_data.amount,
                    show1: !0
                }), a.data.income_data && a.data.income_data.reward_type && e.setData({
                    reward_type: a.data.income_data.reward_type
                }), e._getData()) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    toAdvertising: function() {
        this.setData({
            show1: !1
        });
    }
});